/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nl.maxato.modellen;

import java.util.List;
import javax.swing.table.AbstractTableModel;

import nl.maxato.domain.Differences;

/**
 *
 * @author Danny
 */
public class DifferencesTableModel extends AbstractTableModel {

    private List<Differences> differences;
    String[] columnNames;
    //private Atleet atleet;
    //private List<Usertabel> following;

    public DifferencesTableModel(List<Differences> differences) {
        this.differences = differences;
        //this.atleet = atleet;
        //following = user.getUsertabelCollection();
        //System.out.println("Following: " + atleet.getUsertabelCollection());
    }
    
    public void setColumnNames(String atleet, String soort, String oudeWaarde, String nieuweWaarde, String verschil){
        String[] columnNamesNieuw = {atleet, soort, oudeWaarde, nieuweWaarde, verschil};
       this.columnNames = columnNamesNieuw;
    }

    @Override
    public int getColumnCount() {
        return 5;
    }

    @Override
    public String getColumnName(int col) {
        return columnNames[col];
    }

    @Override
    public int getRowCount() {
        return differences.size();
    }

    @Override
    public Object getValueAt(int row, int col) {
        switch (col) {
            case 0:
                return differences.get(row).getAthlete().getName() + " " + differences.get(row).getAthlete().getSurname();
            case 1:
                return differences.get(row).getName();
            case 2:
                return differences.get(row).getOldValue();
            case 3:
                return differences.get(row).getNewValue();
            case 4:
                return differences.get(row).getNewValue() - differences.get(row).getOldValue();
            default:
                throw new RuntimeException("no such column");
        }
    }

    // This method is used by the JTable to define the default
    // renderer or editor for each cell. For example if you have
    // a boolean data it will be rendered as a check box. A
    // number value is right aligned.
    @Override
    public Class<?> getColumnClass(int columnIndex) {
        switch (columnIndex) {
            case 0:
                return differences.get(0).getAthlete().getName().getClass();
            case 1:
                return differences.get(0).getName().getClass();
            case 2:
                return Integer.class;
            case 3:
                return Integer.class;
            case 4:
                return Integer.class;
            default:
                throw new RuntimeException("no such column");
        }
    }
    
}
